Skip to content

fix: ZipConverter renders '(unknown)' instead of literal 'None' when stream has no source info - #2134

Merged
afourney merged 4 commits into
microsoft:mainfrom
JSap0914:fix/zip-converter-none-filename
Sep 2, 2026
Merged

fix: ZipConverter renders '(unknown)' instead of literal 'None' when stream has no source info#2134
afourney merged 4 commits into
microsoft:mainfrom
JSap0914:fix/zip-converter-none-filename

Conversation

@JSap0914

Copy link
Copy Markdown
Contributor

Bug

When MarkItDown.convert_stream() is called with a ZIP stream that has no associated URL, local path, or filename (e.g. a raw io.BytesIO), the output header renders the literal Python None:

Content from the zip file `None`:

This happens because stream_info.url, stream_info.local_path, and stream_info.filename are all None, and Python f-strings format None as the string 'None'.

Fix

Fall back to '(unknown)' when all three source-info fields are absent:

# Before
file_path = stream_info.url or stream_info.local_path or stream_info.filename

# After
file_path = (
    stream_info.url
    or stream_info.local_path
    or stream_info.filename
    or "(unknown)"
)

The header now reads:

Content from the zip file `(unknown)`:

Verification

pytest packages/markitdown/tests/test_module_misc.py::test_zip_stream_no_filename_header -v
# 1 passed

AI-assisted contribution via automated tooling.

… no source info

When MarkItDown.convert_stream() is called with a ZIP stream that has no
associated URL, local_path, or filename (e.g. a raw io.BytesIO), the
ZipConverter header read:

    Content from the zip file `None`:

because stream_info.url, stream_info.local_path, and stream_info.filename
were all None and Python f-strings render None as the literal string 'None'.

Fix: fall back to '(unknown)' when all three source-info fields are absent,
producing the more descriptive:

    Content from the zip file `(unknown)`:

Add a regression test in test_module_misc.py that verifies the output does
not contain the literal string 'None' in this scenario.
Copilot AI review requested due to automatic review settings June 16, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@JSap0914

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test should assert the exact fallback, and trailing whitespace may fail pre-commit.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread packages/markitdown/tests/test_module_misc.py Outdated
Comment on lines +808 to +809


afourney and others added 2 commits September 1, 2026 23:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@afourney
afourney merged commit 149f8b2 into microsoft:main Sep 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants